package com.yzt.minemodule.adapter;


import android.graphics.Color;
import android.view.View;

import androidx.core.content.ContextCompat;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.module.LoadMoreModule;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.yzt.zhuju.arouter.RouterUser;
import com.yzt.zhuju.network.entity.mine.FriendUserBean;
import com.yzt.minemodule.R;
import com.yzt.plugin_imageloader.ImageLoadUtil;
import com.yzt.zhuju.widget.tuiview.TUITextView;

/**
 * author : bob
 * date   : 2022/12/12
 * desc   : 好友列表适配器
 */
public class FriendListAdapter extends BaseQuickAdapter<FriendUserBean, BaseViewHolder> implements LoadMoreModule {

    public int type;

    public void setType(int type) {
        this.type = type;
    }

    private boolean showBtn;

    public void showMore(boolean showBtn) {
        this.showBtn = showBtn;
    }

    public FriendListAdapter() {
        super(R.layout.item_friend_list);
    }

    @Override
    protected void convert(BaseViewHolder holder, FriendUserBean item) {
        ImageLoadUtil.loadAvatar(getContext(), item.getAvatar(), holder.getView(R.id.avater_riv));
        holder.setText(R.id.nickname_tv, item.getNickName());
        holder.setText(R.id.content_tv, item.getIntro());
        TUITextView follow = holder.findView(R.id.follow_tv);
        if (showBtn) {
            follow.setVisibility(View.VISIBLE);
        } else {
            follow.setVisibility(View.GONE);
        }
        switch (type) {
            case RouterUser.FriendType.TYPE_FOLLOW:
                follow.setText("已关注");
                follow.setTextColor(Color.parseColor("#7D7D7D"));
                follow.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.shape_is_follow));
                break;
            case RouterUser.FriendType.TYPE_FANS:
                follow.setText("回关");
                follow.setTextColor(Color.parseColor("#201F2C"));
                follow.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.shape_follow_back));
                break;
            default:
                follow.setText("私信");
                follow.setTextColor(Color.parseColor("#FFFFFF"));
                follow.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.shape_follow_each));
                break;
        }
    }
}

